using System;
using System.Windows.Forms;
using BizTalk.BuildGenerator.MetaData;
using BizTalk.BuildGenerator.UI.Navigation;

namespace BizTalk.BuildGenerator.UI.UserControls
{
    public partial class UnitTestingControl : UserControl, IWizardControl
    {
        private UnitTesting _unitTesting = new UnitTesting();

        public UnitTestingControl()
        {
            InitializeComponent();
        }

        private void UnitTestingControlLoad(object sender, EventArgs e)
        {
            if (DesignMode) return;           
            UnitTestingPropertyGrid.SelectedObject = _unitTesting;            
        }

        public void RegisterUnitTesting(UnitTesting unitTests)
        {
            _unitTesting = unitTests;
        }

        #region IWizardControl Members

        public MoveNextResult MoveNext()
        {
            var result = new MoveNextResult();

            if (_unitTesting.TestContainers.Count > 0 && string.IsNullOrEmpty(_unitTesting.TestRunConfigPath))
            {
                result.AddError(@"Please supply a test run config");
                result.CanMoveNext = false;
            }
            else
                result.CanMoveNext = true;

            return result;
        }

        #endregion
    }
}